#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/15 17:59
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：add_customer_page.py
"""
添加客户模块
"""
from selenium.webdriver.common.by import By
from pages.cus_mag_pages.base_page import BasePage

class AddCustomerPage(BasePage):

    cust_name_locator = (By.ID,"name")
    contacts_locator = (By.CSS_SELECTOR,".table > tbody:nth-child(1) > tr:nth-child(8) > td:nth-child(2) > input:nth-child(1)")
    mobile_locator = (By.NAME,"con_telephone")
    save_locator = (By.XPATH,"/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td/input[1]")
    def cust_name(self,cust_name):
        """客户名称"""
        self.driver.find_element(*self.cust_name_locator).send_keys(cust_name)
    def contacts_name(self,cts_name):
        """首要联系人"""
        self.driver.find_element(*self.contacts_locator).send_keys(cts_name)
    def mobile_con(self,mobile):
        """手机号"""
        self.driver.find_element(*self.mobile_locator).send_keys(mobile)
    def save_cust(self):
        """保存"""
        self.driver.find_element(*self.save_locator).click()

    def add_cust_func(self,cus_name,cts_name,mobile):
        """填写必要项添加客户"""
        self.cust_name(cus_name)
        self.contacts_name(cts_name)
        self.mobile_con(mobile)
        self.save_cust()



